<?php
/**
 * Created by PhpStorm.
 * User: yafex
 * Date: 2019/12/17
 * Time: 17:57
 */
class serv_rapi_aliReptile extends L {

    /**
     * 描述 ：获取供应商网址
     * 作者 ：Zoro.Zhu
     **/
    public static function getOfferId($offerId = '1137437842'){
        $url = "https://detail.1688.com/offer/{$offerId}.html";
        $res = of_base_com_net::request($url, array('type' => 'get','header' => [
            ':authority:detail.1688.com',
            ':method:GET',
            ':path:/offer/' . $offerId . '.html',
            ':scheme:https',
            'accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
            'accept-encoding:gzip, deflate, br',
            'accept-language:zh-CN,zh;q=0.9,en;q=0.8',
            'cache-control:no-cache',
            'cookie:cna=Ihp6FnCPoQkCAXFX417gTnXx; ali_ab=119.123.178.223.1576220599376.6; h_keys="%u6295%u5f71%u4eea"; UM_distinctid=16efe12a03eba8-0a3b8ac1077fea-7711a3e-1fa400-16efe12a03f992; taklid=431d6a2594564ed9ba9dad197d25d1e5; lid=%E6%9C%B1%E5%A4%A7%E8%A1%A8%E5%93%A5%E5%AE%B6; ali_apache_track=c_mid=b2b-30166166470823c|c_lid=%E6%9C%B1%E5%A4%A7%E8%A1%A8%E5%93%A5%E5%AE%B6|c_ms=1|c_mt=1; t=8a2d275a83e8e17fd4bbc79b93b92ed5; ad_prefer="2019/12/28 15:58:19"; cookie1=UtMK%2BAHqFGDE%2FePmzmwOkBAuT96qcEhIo9kOp4emjOM%3D; cookie2=18df0982ab7b14ff8c65ede050d9360e; cookie17=UNDVdFaHcwp4hg%3D%3D; _tb_token_=3a4ded1e3ab4e; sg=%E5%AE%B676; csg=29da280d; unb=3016616647; uc4=nk4=0%40txNq15RAaR21MCy9CFT3SjS0H1eL&id4=0%40UgclGbC%2FG49F1vo97AkEuyETnoBd; __cn_logon__=true; __cn_logon_id__=%E6%9C%B1%E5%A4%A7%E8%A1%A8%E5%93%A5%E5%AE%B6; ali_apache_tracktmp=c_w_signed=Y; _nk_=%5Cu6731%5Cu5927%5Cu8868%5Cu54E5%5Cu5BB6; last_mid=b2b-30166166470823c; _csrf_token=1577689031990; _is_show_loginId_change_block_=b2b-30166166470823c_false; _show_force_unbind_div_=b2b-30166166470823c_false; _show_sys_unbind_div_=b2b-30166166470823c_false; _show_user_unbind_div_=b2b-30166166470823c_false; __rn_alert__=false; CNZZDATA1253659577=1403307438-1576220337-https%253A%252F%252Fs.1688.com%252F%7C1577693753; alicnweb=touch_tb_at%3D1577695308519%7Clastlogonid%3D%25E6%259C%25B1%25E5%25A4%25A7%25E8%25A1%25A8%25E5%2593%25A5%25E5%25AE%25B6; JSESSIONID=1F13E5FF387C698E70ED2D960854B43F; l=cBLN-ob4qd8FPEnkBOCwourza77ObIRAguPzaNbMi_5ZxOL65N7Oof_XBHp6cjWd9kTB47_ypVw9-etkmeIA7SG62E2l.; isg=BOPjwZy-ucMZyXYNKVTqAftzcieN2HcaiZ8AWBVABcK5VAN2naszateGTmR_dM8S',
            'pragma:no-cache',
            'sec-fetch-mode:navigate',
            'sec-fetch-site:none',
            'sec-fetch-user:?1',
            'upgrade-insecure-requests:1',
            'user-agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36',
        ],
        ));
        $xPaths = array(
            //供应商网址
            'manu' => array(
                'xPath' => '//*[@id="topnav"]/div/ul/li[3]/a',
                'attr' => 'href',
            ),
        );
        $xPathRe = helpers_xtmDec::xPath($res['response'], $xPaths);
        if(!empty($xPathRe['manu'][0]['content'])){
            return $xPathRe['manu'][0]['content'];
        }
        return false;
    }

    /**
     * 描述 ：获取供应商网址中的信息
     * 作者 ：Zoro.Zhu
     **/
    public static function getManu($manu = '13316008708'){
        $url = "https://{$manu}.1688.com/page/merchants.htm";
        $res = of_base_com_net::request($url, array('type' => 'get','header' => [
            ':authority:{$manu}.1688.com',
            ':method:GET',
            ':path:/fragment/merchants.htm?page_type=merchants&apps=%5B%7B%22appName%22%3A%22winport_public_dialog%22%7D%2C%7B%22appName%22%3A%22couponLayer%22%7D%2C%7B%22appName%22%3A%22collectWinport%22%7D%5D&_=1577689045386',
            ':scheme:https',
            'accept:application/json, text/javascript, */*; q=0.01',
            'accept-encoding:gzip, deflate, br',
            'accept-language:zh-CN,zh;q=0.9,en;q=0.8',
            'cache-control:no-cache',
            'cookie:cna=Ihp6FnCPoQkCAXFX417gTnXx; ali_ab=119.123.178.223.1576220599376.6; h_keys="%u6295%u5f71%u4eea"; UM_distinctid=16efe12a03eba8-0a3b8ac1077fea-7711a3e-1fa400-16efe12a03f992; taklid=431d6a2594564ed9ba9dad197d25d1e5; lid=%E6%9C%B1%E5%A4%A7%E8%A1%A8%E5%93%A5%E5%AE%B6; ali_apache_track=c_mid=b2b-30166166470823c|c_lid=%E6%9C%B1%E5%A4%A7%E8%A1%A8%E5%93%A5%E5%AE%B6|c_ms=1|c_mt=1; t=8a2d275a83e8e17fd4bbc79b93b92ed5; ad_prefer="2019/12/28 15:58:19"; alicnweb=touch_tb_at%3D1577688980505%7Clastlogonid%3D%25E6%259C%25B1%25E5%25A4%25A7%25E8%25A1%25A8%25E5%2593%25A5%25E5%25AE%25B6; cookie1=UtMK%2BAHqFGDE%2FePmzmwOkBAuT96qcEhIo9kOp4emjOM%3D; cookie2=18df0982ab7b14ff8c65ede050d9360e; cookie17=UNDVdFaHcwp4hg%3D%3D; _tb_token_=3a4ded1e3ab4e; sg=%E5%AE%B676; csg=29da280d; unb=3016616647; uc4=nk4=0%40txNq15RAaR21MCy9CFT3SjS0H1eL&id4=0%40UgclGbC%2FG49F1vo97AkEuyETnoBd; __cn_logon__=true; __cn_logon_id__=%E6%9C%B1%E5%A4%A7%E8%A1%A8%E5%93%A5%E5%AE%B6; ali_apache_tracktmp=c_w_signed=Y; _nk_=%5Cu6731%5Cu5927%5Cu8868%5Cu54E5%5Cu5BB6; last_mid=b2b-30166166470823c; _csrf_token=1577689031990; _is_show_loginId_change_block_=b2b-30166166470823c_false; _show_force_unbind_div_=b2b-30166166470823c_false; _show_sys_unbind_div_=b2b-30166166470823c_false; _show_user_unbind_div_=b2b-30166166470823c_false; __rn_alert__=false; isg=BJWVwp7HZ90cIkDbq84Ez5nppJFPkkmkK7WW7hc63oxbbrRg3uEMdflnPDL97mFc; l=cBLN-ob4qd8FPapJBOfZourza77OmIRb8sPzaNbMiICP_71HSZjFWZc1URTMCnGVLsEDJ3P5zp3_Bc8iJy4EghmqtRGr2g2h.',
            'pragma:no-cache',
            'referer:https://{$manu}.1688.com/page/merchants.htm',
            'sec-fetch-mode:cors',
            'sec-fetch-site:same-origin',
            'user-agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36',
            'x-requested-with:XMLHttpRequest',
        ],
        ));
        $xPaths = array(
            //供应商网址
            'manu' => array(
                'xPath' => '//*[@id="ali-masthead-v6"]/div/div[2]/div[1]/div[1]/div[1]/div[2]/span[2]',
                'attr' => 'data-nick',
            ),
        );
        $xPathRe = helpers_xtmDec::xPath($res['response'], $xPaths);
        if(!empty($xPathRe['manu'][0]['content'])){
            return $xPathRe['manu'][0]['content'];
        }
        return false;
    }

}